﻿using System.Diagnostics;

namespace directiongame
{
    internal class Program
    {
        
        static void Main(string[] args)
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            int errornum = 0;
            for (int i = 0; i < 10; i++)//设置游戏次数是10次
            {
                int m;
                Random rd = new Random();
                m = rd.Next(1, 5);
                char c = '0';
                Console.WriteLine("游戏说明：W键是前进，S键是后退，A键是向左，D键是向右");//进行游戏说明
                switch (m)
                {
                    case 1: Console.Write("Up");  c = 'w'; break;
                    case 2: Console.Write("Down"); c = 's'; break;
                    case 3: Console.Write("Left"); c = 'a'; break;
                    case 4: Console.Write("Right"); c = 'd'; break;
                }
                Console.WriteLine($"   Errortime:{errornum}");
                char input = Console.ReadKey(true).KeyChar;
                if (input != c) errornum++;
                Console.Clear();
            }
            Console.WriteLine($"您的错误次数是：{errornum}次");//显示最终错误次数
            sw.Stop();
            TimeSpan ts2 = sw.Elapsed;
            Console.WriteLine("本程序总共花费{0}ms.", ts2.TotalMilliseconds);//统计程序执行时间

        }
    }
}